package com.atguigu.stgy.admin.controller;

import com.atguigu.stgy.admin.service.AttrValueService;
import com.atguigu.stgy.model.entity.AttrValue;
import com.atguigu.stgy.admin.service.impl.AttrValueServiceImpl;
import com.atguigu.stgy.model.result.R;
import com.atguigu.stgy.model.result.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 房间基本属性值表(attr_value)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/admin/attr")
public class AttrValueController {
    /**
     * 服务对象
     */
    @Resource
    private AttrValueService attrValueService;

    // http://localhost:8080/admin/attr/value/deleteById?id=22
    @DeleteMapping("value/deleteById")
    @Operation(summary = "房间基本信息管理删除")
    public R deleteById(@RequestParam("id") Long id) {
        return R.ok(attrValueService.removeById(id));
    }


  //  http://localhost:8080/admin/attr/value/saveOrUpdate

    @Operation(summary = "房间基本信息新增/删除")
    @PostMapping("value/saveOrUpdate")
    public R<List<AttrValue>> saveOrUpdate(@RequestBody AttrValue attrValue){
        boolean b = attrValueService.saveOrUpdate(attrValue);
        return  b?R.ok():R.fail(ResultCodeEnum.FAIL);

    }
}
